package com.errol.batchprocessor.payroll.advisorimpl.payload;

import com.renjia.constant.Constant;
import com.renjia.entity.CoreCustomerChannelMerchant;
import com.renjia.enums.PayLimitEnum;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;

/**
 * 发放限制配置项
 *
 * @author zhang xiao bin
 * @version v1.0
 * @date 2021/03/06
 * @since v5.0.6
 **/
@Getter
public class PayLimitPayload {

    //是否有限制
    private boolean payLimit = false;
    //只发已认证
    private Boolean payAuthenticationFlag = null;
    //只发未认证
    private Boolean payNoAuthenticationFlag = null;
    //只发已签约
    private Boolean paySigningFlag = null;
    //只发未签约
    private Boolean payNoSigningFlag = null;
    //v4.8.8只发已接单
    private Integer orderReceivingLimit = null;
    // 月限额
    private BigDecimal monthLimitAmount = null;
    // 个体户
    private volatile boolean needCheckGqc = false;

    public PayLimitPayload(CoreCustomerChannelMerchant coreCustomerChannelMerchant) {
        // 发薪有限制
        if (StringUtils.equals(PayLimitEnum.ONLY_EXIST.getCode().toString(), coreCustomerChannelMerchant.getPayLimitFlag())) {
            payLimit = true;
            payAuthenticationFlag = coreCustomerChannelMerchant.getPayAuthenticationFlag();
            payNoAuthenticationFlag = coreCustomerChannelMerchant.getPayNoAuthenticationFlag();
            paySigningFlag = coreCustomerChannelMerchant.getPaySigningFlag();
            payNoSigningFlag = coreCustomerChannelMerchant.getPayNoSigningFlag();
            orderReceivingLimit = coreCustomerChannelMerchant.getOrderReceivingLimit() == null ? Constant.COMMON_ONE : coreCustomerChannelMerchant.getOrderReceivingLimit();
        }
        monthLimitAmount = coreCustomerChannelMerchant.getMonthLimitAmount() == null ? BigDecimal.ZERO : coreCustomerChannelMerchant.getMonthLimitAmount();
    }

    public void setNeedCheckGqc(boolean needCheckGqc) {
        this.needCheckGqc = needCheckGqc;
    }
}
